package com.xtwy.admin.web.service.impl;

import com.xtwy.admin.web.mapper.AdminAndRoleMapper;
import com.xtwy.admin.web.model.pojo.AdminAndRole;
import com.xtwy.admin.web.service.AdminAndRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 类的描述：
 *
 * @作者: 侯建军
 * @邮箱: 474177818@qq.com
 * @博客: https://blog.csdn.net/marquis888
 * @创建日期: 2018年11月18日  23:07
 * @版本: v1.0
 * @jdk版本使用: JDK1.8
 */
@Service
@Slf4j
public class AdminAndRoleServiceImpl implements AdminAndRoleService {
    @Autowired
    private AdminAndRoleMapper adminAndRoleMapper;

    public void insert(AdminAndRole adminAndRole){
        adminAndRoleMapper.insert(adminAndRole);
    }

    public void deleteAdminId(String id){
        Example example = new Example(AdminAndRole.class);
        example.createCriteria().andCondition("admin_id =", id);
        adminAndRoleMapper.deleteByExample(example);
    }

    public void deleteRoleId(String id){
        Example example = new Example(AdminAndRole.class);
        example.createCriteria().andCondition("role_id =", id);
        adminAndRoleMapper.deleteByExample(example);
    }

    public AdminAndRole selectOne(AdminAndRole adminRole){
        return adminAndRoleMapper.selectOne(adminRole);
    }

    public List<AdminAndRole> getRoleList(AdminAndRole adminRole){
        return adminAndRoleMapper.select(adminRole);
    }

}
